/**
 * for index.html
 */

// 伪jQuery的$
function $(elemId) {
    return document.getElementById(elemId);
}

// 鼠标移入 mouseover
function boxOver(index) {
    switch (index) {
        case 1:
        case 5:
            setBox(index, "#fff", "#d97873", getBgImg(index))
            break
        case 2:
        case 6:
            setBox(index, "#fff", "#05bf6c", getBgImg(index))
            break
        case 3:
        case 4:
            setBox(index, "#fff")
            break
    }
}

// 鼠标移出 mouseout
function boxOut(index) {
    for (let i = 1; i <= 6; i++) {
        // 清除索引元素的设置
        if (i === index) setBox(i, "", "", "")
    }
}

function getBgImg(index) {
    return "url(./imgs/text_" + index + ".png)";
}

// 对索引的div进行设置
function setBox(caseIndex, bgColor = undefined, color = undefined, bgImg = undefined) {
    $('box_' + caseIndex).style.backgroundColor = bgColor;
    $('text_' + caseIndex).style.color = color;
    if (bgImg !== undefined) {
        $('box_1' + caseIndex).style.backgroundImage = bgImg;
    }
}
